import vue from 'vue'
import vuex from 'vuex'

vue.use(vuex)

export default new vuex.Store({
  state: {
    routes: [],
    userInfo: [],
  },

  // 同步
  mutations: {
    initRoutes(state, data) {
      state.routes = data;
      localStorage.setItem("routers", JSON.stringify(data));
    },

    userInfo(state, data) {
      state.userInfo = data;
      localStorage.setItem("userInfo", JSON.stringify(data));
    },

  },

  // 异步
  actions: {

  }
})

